package com.zhaopin.valatile;

/**
 * @author Administrator
 * @create 2021-02-26 11:38
 */
public class VolatileData {

    //声明为volatile类型
    private volatile int counter = 0;

    /**
     * 返回counter变量的值
     *
     * @return
     */
    public int getCounter() {
        return counter;
    }

    /**
     * 自增counter变量的值
     */
    public void increaseCounter() {
        ++counter;
    }
}
